const createError = require("http-errors");
const logger = require("morgan");
const express = require("express");
const path = require("path");
const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const app = express();
const http = require("http");
const server = http.createServer(app);
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());

//路由
const indexRouter = require("./routes");
const usersRouter = require("./routes/users");


//定义模版引擎
app.engine('.html', require('express-art-template'));
app.set('view engine', 'html');
app.set('views',path.join(__dirname,'views'))


// 静态资源
app.use(express.static(path.join(__dirname, "public")));

//post请求
app.use(bodyParser.urlencoded({extended: true}))
app.use("/", indexRouter);
app.use("/users", usersRouter);

//监听端口
server.listen(3000, () => console.log("http://localhost:3000"));
